<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex align-stretch benben-position-layout flex searchPage_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center justify-between flex-sub searchPage_fd0_0'>
          <view class='flex align-center justify-center searchPage_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  searchPage_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex align-center flex-sub searchPage_fd0_0_c1'>
            <input class='flex-sub searchPage_fd0_0_c1_c0' type="text" :focus='true' :placeholder="$t('搜索你想要的经文')"
              confirm-type="done" :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx"
              @confirm="addSearchFunc()" v-model="keyworld" />
          </view>
          <view class='flex flex-wrap align-center justify-center searchPage_fd0_0_c2'>
            <image class='searchPage_fd0_0_c2_c0' mode="aspectFit" :src='STATIC_URL+"103.png"'
              @tap.stop="addSearchFunc()"></image>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---历史搜索flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
        <view class='flex flex-wrap align-center searchPage_fd1_0'>
          <image class='searchPage_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"64.png"'></image>
          <text class='searchPage_fd1_0_c1'>{{$t('历史搜索')}}</text>
          <image class='searchPage_fd1_0_c2' mode="aspectFit" :src='STATIC_URL+"104.png"'
            @tap.stop="popupShow1703165438856=true"></image>
        </view>
        <view class='flex flex-wrap align-center searchPage_fd1_1'>
          <view class='flex flex-wrap align-center'>
            <template v-for='(item,key0) in appSearchHistory'>
              <view class='flex flex-wrap align-center searchPage_fd1_1_c0_c0' @longpress="deleteSearchFunc(item.name)"
                :key='key0'>
                <text class='searchPage_fd1_1_c0_c0_c0'>{{item.name}}</text>
                <image class='searchPage_fd1_1_c0_c0_c1' mode="aspectFit" :src='STATIC_URL+"65.png"'
                  @tap.stop="deleteSearchFunc(item.name)"></image>
              </view>
            </template>

          </view>
        </view>
        <view class='flex flex-wrap align-center searchPage_fd1_2' v-if=" appSearchHistory.length<'1'">
          <text class='searchPage_fd1_2_c0'>{{$t('暂无历史记录')}}</text>
        </view>
      </view>

      <!---历史搜索flex布局结束-->
      <benben-popup v-model="popupShow1703165438856" :mask="true" :mask-close-able="false" mode='center'>
        <!---删除弹窗flex布局开始-->
        <view class="flex flex-direction flex-wrap align-center searchPage_flex_2">
          <text class='searchPage_fd2_0'>{{$t('确认删除历史记录吗')}}？</text>
          <view class='flex flex-wrap align-center searchPage_fd2_1'>
            <button class='searchPage_fd2_1_c0' @tap.stop="popupShow1703165438856=false">{{$t('取消')}}</button>
            <button class='searchPage_fd2_1_c1' @tap.stop="clearSearchFunc()">{{$t('确认')}}</button>
          </view>
        </view>

        <!---删除弹窗flex布局结束-->

      </benben-popup>


    </view>
  </view>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        "popupShow1703165438856": false,
        "keyworld": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      appSearchHistory() { // 搜索历史
        return this.$store.state.appSearchHistory
      }
    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //添加历史搜索
      addSearchFunc() {
        this.$store.commit('appSearchHistoryAdd', {
          "name": this.keyworld
        })
        this.$urouter.navigateTo(`/pages/fyql/searchResult/searchResult?keyworrld=${this.keyworld}`);
      },
      //删除搜索id
      deleteSearchFunc(name) {
        console.log('id',name)
        this.$store.commit('appSearchHistoryDel', {
          "name": name
        })
      },
      //清空搜索历史
      clearSearchFunc() {
        this.$store.commit('appSearchHistoryClean', '')
        this.popupShow1703165438856 = false;
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(247, 243, 237, 1);
    background-size: 100% auto;
  }

  .searchPage_flex_0 {
    border-bottom: 1px solid #eee;
    background: rgba(247, 243, 237, 1);
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .searchPage_fd0_0_c2_c0 {
    width: 40rpx;
    height: 40rpx;
  }

  .searchPage_fd0_0_c2 {
    margin: 0rpx 0rpx 0rpx 24rpx;
    width: 40rpx;
    height: 40rpx;
  }

  .searchPage_fd0_0_c1_c0 {
    font-size: 28rpx;
    font-weight: 400;
    color: #333;
  }

  .searchPage_fd0_0_c1 {
    background: #F9F9F9;
    height: 64rpx;
    border-radius: 34rpx 34rpx 34rpx 34rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    margin: 0rpx 0rpx 0rpx 24rpx;
  }

  .searchPage_fd0_0_c0_c0 {
    font-size: 32rpx;
    color: #333;
    line-height: 28rpx;
  }

  .searchPage_fd0_0_c0 {
    width: 50rpx;
    height: 50rpx;
  }

  .searchPage_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .searchPage_fd1_2_c0 {
    font-size: 24rpx;
    font-weight: 400;
    color: #666666;
  }

  .searchPage_fd1_2 {
    margin: 0rpx 16rpx 0rpx 33rpx;
  }

  .searchPage_fd1_1_c0_c0_c1 {
    width: 16rpx;
    height: 16rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 8rpx;
  }

  .searchPage_fd1_1_c0_c0_c0 {
    color: #333333;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 34rpx;
  }

  .searchPage_fd1_1_c0_c0 {
    background: rgba(255, 255, 255, 1);
    padding: 12rpx 40rpx 12rpx 40rpx;
    border-radius: 40rpx;
    background-size: 100% auto;
    margin: 0rpx 24rpx 24rpx 0rpx;
  }

  .searchPage_fd1_1 {
    margin: 0rpx 16rpx 0rpx 30rpx;
  }

  .searchPage_fd1_0_c2 {
    width: 24rpx;
    height: 28rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .searchPage_fd1_0_c1 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    margin: 0rpx 0rpx 0rpx 17rpx;
  }

  .searchPage_fd1_0_c0 {
    width: 28rpx;
    height: 28rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .searchPage_fd1_0 {
    margin: 31rpx 33rpx 24rpx 32rpx;
  }

  .searchPage_flex_2 {
    background: #fff;
    width: 540rpx;
    border-radius: 40rpx;
  }

  .searchPage_fd2_1_c1 {
    border-top: 1px solid #eee;
    border-left: 1px solid #eee;
    background: #fff;
    line-height: 110rpx;
    border-radius: 0rpx 0rpx 16rpx 0rpx;
    font-size: 32rpx;
    color: rgba(145, 47, 34, 1);
    font-weight: 500;
    width: 270rpx;
  }

  .searchPage_fd2_1_c0 {
    border-top: 1px solid #eee;
    background: #fff;
    line-height: 110rpx;
    border-radius: 0rpx 0rpx 0rpx 16rpx;
    font-size: 32rpx;
    color: rgba(153, 153, 153, 1);
    font-weight: 500;
    width: 270rpx;
  }

  .searchPage_fd2_1 {
    margin: 37rpx 0rpx 0rpx 0rpx;
  }

  .searchPage_fd2_0 {
    line-height: 52rpx;
    font-size: 32rpx;
    font-weight: 400;
    color: #333333;
    margin: 80rpx 32rpx 0rpx 32rpx;
    text-align: center;
  }
</style>
